* scroll-bar.el (scroll-bar-mode): Variable deleted.
authorJim Blandy <jimb@redhat.com>
Thu, 10 Jun 1993 12:18:36 +0000 (12:18 +0000)
committerJim Blandy <jimb@redhat.com>
Thu, 10 Jun 1993 12:18:36 +0000 (12:18 +0000)
(scroll-bar-mode): Function changed to consult default-frame-alist
instead of the variable.

lisp/scroll-bar.el

index 3e30e1b5e7de89511581893b2a9f39eeb8782565..8fd62f02898427f33f2db5d3e89f314f1b542299 100644 (file)
@@ -48,9 +48,6 @@ that scroll bar position."
 
 \f
 ;;;; Helpful functions for enabling and disabling scroll bars.
-;;; This is not documented because you can't change the 
-;;; mode properly by setting it.
-(defvar scroll-bar-mode t)
 
 (defun scroll-bar-mode (flag)
   "Toggle display of vertical scroll bars on each frame.
@@ -59,25 +56,36 @@ created in the future.
 With a numeric argument, if the argument is negative,
 turn off scroll bars; otherwise, turn on scroll bars."
   (interactive "P")
-  (setq scroll-bar-mode (if (null flag) (not scroll-bar-mode)
-                         (or (not (numberp flag)) (>= flag 0))))
-  (mapcar
-   (function
-    (lambda (param-name)
-      (let ((parameter (assq param-name default-frame-alist)))
-       (if (consp parameter)
-           (setcdr parameter scroll-bar-mode)
-         (setq default-frame-alist
-               (cons (cons param-name scroll-bar-mode)
-                     default-frame-alist))))))
-   '(vertical-scroll-bars horizontal-scroll-bars))
-  (let ((frames (frame-list)))
-    (while frames
-      (modify-frame-parameters
-       (car frames)
-       (list (cons 'vertical-scroll-bars scroll-bar-mode)
-            (cons 'horizontal-scroll-bars scroll-bar-mode)))
-      (setq frames (cdr frames)))))
+
+  ;; Obtain the current setting by looking at default-frame-alist.
+  (let ((scroll-bar-mode
+        (let ((assq (assq 'vertical-scroll-bars default-frame-alist)))
+          (if assq (cdr assq) t))))
+
+    ;; Tweedle it according to the argument.
+    (setq scroll-bar-mode (if (null flag) (not scroll-bar-mode)
+                           (or (not (numberp flag)) (>= flag 0))))
+
+    ;; Apply it to default-frame-alist.
+    (mapcar
+     (function
+      (lambda (param-name)
+       (let ((parameter (assq param-name default-frame-alist)))
+         (if (consp parameter)
+             (setcdr parameter scroll-bar-mode)
+           (setq default-frame-alist
+                 (cons (cons param-name scroll-bar-mode)
+                       default-frame-alist))))))
+     '(vertical-scroll-bars horizontal-scroll-bars))
+
+    ;; Apply it to existing frames.
+    (let ((frames (frame-list)))
+      (while frames
+       (modify-frame-parameters
+        (car frames)
+        (list (cons 'vertical-scroll-bars scroll-bar-mode)
+              (cons 'horizontal-scroll-bars scroll-bar-mode)))
+       (setq frames (cdr frames))))))
 \f
 ;;;; Buffer navigation using the scroll bar.